<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>首页</title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap-table.min.css" />
<script type="text/javascript">
var pwdList;
$(function (){
	pwdList = $("#pwdList").bootstrapTable({
		url : '${_baseUrl}/myWorkbench/selectPwdMessage?rand='+Math.random(),
		pagination: true,
		pageList: [5, 10, 20, 50],
		clickToSelect:false,
		cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
  		queryParams: queryParams,
        columns: [{
            title: '序号',
            width: 40,
            formatter: function(value, row, index){
            	return index+1;
            }
        }, {
            field: 'id',
            title: 'id',
            visible:false,
            width: 5
        },{
            field: 'userId',
            title: '用户账号',
            width: 100
        },{
            field: 'userName',
            title: '姓名',
            width: 200
        },{
            field: 'deptName',
            title: '部门',
            width: 100
        },{
            field: 'post',
            title: '职务',
            width: 100
        },{
            field: 'userCreationTime',
            title: '重置密码时间',
            width: 100
        },{
            field: '',
            title: '操作',
            width: 100,
            formatter: function(value, row, index){
            	if(row.departId== '0'){
               	   return "<a href='javascript:void(0)' onclick='confirm(\""+row.id+"\",\""+row.password+"\")'>确认</a>"; 
            	}else{
            		return "---";
            	}
            }
        }]
    });
	
	/* 项目名称缺省显示 */
	function subProjectName(name){
		if(name.length > 15){
			name = name.substring(0,15);
			name += "...";
		}
		return name;
	}
	function queryParams(params){
		return {
		    pageSize: params.limit,
		    pageNo: params.pn,
		    sort : params.sort,
		    order : params.order,
	   }
	}
});

function  confirm(id,userId){
	 sigh(id);
	 var path="${_baseUrl}/userController/PwdResetMessage";
	 if("${customCode}" == "tianjin712suo"){
		 path="${_baseUrl}/user/passWordForceUpdate/PwdResetMessage";
	 }
	
	 $.ajax({    
		type: "POST",    
		async: false,    
		url:path,   
		data:{
			"userIds":userId ,
		},    
		success: function () {   
			layer.msg("重置成功");
			refreshTable();
		} ,
		error:function(json){
			layer.msg("系统错误,请联系管理员");
		}  
	}); 
}
function sigh(messageId){
	$.ajax({
		url : '${_baseUrl}/workbench/updateNeedHandleEventNew?id='+messageId,
		type : 'post', //数据发送方式 
		dataType : 'json', //接受数据格式 
		async : false,
		success : function(json) {
		},
		error : function() {
			layer.msg("系统错误,请联系管理员");
		}
	});	
}
function refreshTable(){
	parent.refreshTable();
	pwdList.bootstrapTable('refresh');
}
</script>
</head>
<body>
	<div class="main">
      <div style="overflow: auto; width:98%;margin: auto;">
	     <table class="table table-bordered table_inline" id="pwdList"></table>           
    </div>
</div> 
</body>
</html>